import json


with open("./processed/mrpc.txt", "r", encoding="utf-8") as f_in:
    with open("./processed/mrpc.json", "w", encoding="utf-8") as f_out:
        output = []
        template = dict()
        for i, line in enumerate(f_in.readlines()):
            if i % 6 == 0:
                template["instruction"] = line.strip()
            elif i % 6 == 1:
                template["input"] = line.strip()
            elif i % 6 == 2:
                template["input"] += '\n' + line.strip()
            elif i % 6 == 3:
                template["output"] = line.strip()
            elif i % 6 == 5:
                output.append(template)
                template = dict()
        json.dump(output, f_out, indent=4, ensure_ascii=False)
